package com.atguigu.controller;

import com.atguigu.common.result.R;
import com.atguigu.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@CrossOrigin
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;
     @GetMapping("{page}/{limit}")
    public R index(@PathVariable Integer page, @PathVariable Integer limit,HospitalQueryVo hospitalQueryVo){
         Page<Hospital> pageResult = hospitalService.selectPage(page,limit,hospitalQueryVo);
         List<Hospital> content = pageResult.getContent();
         long totalElements = pageResult.getTotalElements();
         return R.ok().data("pages",pageResult);
     }
     //更新数据
    @GetMapping("updateStatus/{id}/{status}")
    public R  updateStatus(@PathVariable("id") String id,@PathVariable("status") Integer status){
         hospitalService.updateStatus(id,status);
         return  R.ok();
    }
    @GetMapping("show/{id}")
    public R  show(@PathVariable String id){
         return  R.ok().data("hospital",hospitalService.show(id));
    }



}
